home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: PieXCMD.c
- *
- * Purpose: XCMD interface for pie popup menus.
- *
- */
- #include <MacTypes.h>
- #include <MenuMgr.h>
- #include <QuickDraw.h>
- #include <SetUpA4.h>
- #include "HyperXCmd.h"
-
-
- /* Local function prototypes. */
- pascal void main(XCmdBlockPtr);
-
- /* External function prototypes.*/
- int GetLocOfCardWindow(XCmdBlockPtr, Point *);
- Handle CopyStrToHand(char *);
- long HandleToNum(XCmdBlockPtr, Handle);
- void HandleToPstr(Str255, Handle);
- char *ToCstr(char *);
- char *ToPstr(char *);
-
-
-
- #define ERRORFLAG (short) -1
- #define MENU_SEPARATOR ';'
- #define USAGE "Usage: put \
- PiePopup(\"Menu;list\", \
- font#,fontsize,pat_flag) \
- into container"
-
-
-
-
- pascal void
- main(XCmdBlockPtr paramPtr)
- {
- Str255 menuList; /* list of menu items */
- int num_menu_items; /* # of menu items */
- char tempStr[32]; /* str scratch buffer */
- int selection; /* menu item selected */
- Point cardWindowLoc; /* popup positioner */
- int font = geneva; /* selected font */
- int font_size = 10; /* selected size */
- int pattern_flag = TRUE;/*use patterns*/
-
-
- /*
- * LightSpeed C allows global variables to be
- * referenced from A4.
- */
- RememberA0();
- SetUpA4();
-
- /*
- * Make sure we were called with the proper
- * number of arguments.
- */
- if (paramPtr->paramCount > 4) {
- paramPtr->returnValue =
- (Handle) CopyStrToHand(USAGE);
- return;
- }
-
- /*
- * Bias the origin of the popup by
- * HyperCard's window location
- */
- if ((GetLocOfCardWindow(
- paramPtr,&cardWindowLoc)) == ERRORFLAG) {
- return;
- }
-
- /* Buffer the menu list. */
- strcpy(menuList, *paramPtr->params[0]);
-
- /*
- * Strip the features that are supported by
- * the Mac's menu manager but we ignore.
- * These include: line separators, check
- * marks, icons, etc.
- */
- num_menu_items = ConvertMenuList(menuList);
-
-
- /* Obtain any optional parameters */
- if ((paramPtr->paramCount > 1) &&
- (paramPtr->params[1] != '\0'))
- font = (int) HandleToNum(
- paramPtr, paramPtr->params[1]);
-
- if ((paramPtr->paramCount > 2) &&
- (paramPtr->params[2] != '\0'))
- font_size = (int) HandleToNum(
- paramPtr, paramPtr->params[2]);
-
- if ((paramPtr->paramCount > 3) &&
- (paramPtr->params[3] != '\0'))
- pattern_flag = (int) HandleToNum(
- paramPtr, paramPtr->params[3]);
-
-
- /* Put up the pie popup menu */
- selection = DrawPieMenu(cardWindowLoc,
- menuList,
- num_menu_items,
- font,
- font_size,
- pattern_flag);
-
- /* Return the menu selection to HyperCard */
- NumToStr(paramPtr,
- (long) selection,
- (unsigned char *) tempStr);
- paramPtr->returnValue =
- (Handle) CopyStrToHand(ToCstr((char *) tempStr));
-
- /* Recover original A4 and return */
- RestoreA4();
- return;
- }
-
-
-
-